/**
 * 
 */
import * as api from '../../api/index'
import { Notification } from 'element-ui';
const state={
	   data:[],//列表数据
	   loading:false
}
const actions = {
    //获取角色列表
	getData({commit}){
		commit('update',{type:'loading',data:true});
		api.role.getData({},res=>{
			commit('update',{type:'loading',data:false});
				if(res.status==1) {
					commit('update',{type:'data',data:res.data});//更新数据
				}
			    else Notification(res);
			});
	}
}

const mutations = {
    update(state,p){//更新数据状态
    	state[p.type] = p.data;
    	},
	del(state,str){//删除数据
		eval(str);
	},
	/*
	loading(state,data){
		state.loading=data;
	}*/
}

export default {
  namespaced: true,
  state,
  //getters,
  actions,
  mutations
}